<template>
  <div class="detail">

    <app-head title="礼包详情"></app-head>

    <div class="detail__head">
      <img :src="giftDetail.icon" class="detail__icon">
      <div class="detail__info">
        <p class="detail__title">{{giftDetail.title}}</p>
        <p class="detail__code" v-if="false">兑换码：{{giftDetail.code}}</p>
        <p class="detail__remain" v-else>剩余数量：<span>{{giftDetail.remain_cnt}}</span></p>
      </div>
      <GiftItem :item="giftDetail" :onlyBtn="true"/>
    </div>
    <div class="detail__body">
      <div class="detail__item">
        <div class="detail__item_title">礼包内容</div>
        <div class="detail__item_content">{{giftDetail.content}}</div>
      </div>
      <div class="detail__item">
        <div class="detail__item_title">使用范围</div>
        <div class="detail__item_content">{{giftDetail.scope}}</div>
      </div>
      <div class="detail__item">
        <div class="detail__item_title">使用方法</div>
        <div class="detail__item_content">{{giftDetail.func}}</div>
      </div>
    </div>
  </div>
</template>

<script>
import { mapGetters } from 'vuex'
import GiftItem from '@/components/gift/Item'

export default {
  name: 'giftDetail',
  components: {
    GiftItem
  },
  computed: {
    ...mapGetters([
      'giftDetail'
    ])
  },
  created () {
    let { id } = this.$route.params
    if (id) {
      this.$store.dispatch('getGiftDetail', {
        gift_id: id
      })
    }
  },
  methods: {
    addGift (id) {
      this.$store.dispatch('addGift', {
        gift_id: id
      })
    }
  }
}
</script>

<style scoped lang="scss">
.detail {
  &__head {
    align-items: center;
    display: flex;
    padding: 0.35rem 0.15rem;
  }

  &__icon {
    border-radius: 0.1rem;
    height: 0.57rem;
    margin-right: 0.18rem;
    width: 0.57rem;
  }

  &__info {
    flex: 1;
  }

  &__title {
    color: #333;
    font-size: 0.15rem;
    font-weight: bold;
    margin-bottom: 0.1rem;
  }

  &__code,
  &__remain {
    color: #249AFF;
    font-size: 0.13rem;
  }
  &__remain {
    color: #666;
    span{
      color: #249AFF;
      font-size: 0.2rem !important;
    }
  }

  &__btn {
    height: 0.26rem;
    width: 0.52rem;
  }

  &__body {
    padding: 0 0.15rem;
  }

  &__item {
    margin-top: 0.3rem;

    &_title {
      border-left: 0.05rem solid #249AFF;
      color: #333;
      font-size: 0.16rem;
      line-height: 1;
      margin-bottom: 0.12rem;
      padding-left: 0.1rem;
    }

    &_content {
      color: #666;
      font-size: 0.13rem;
    }
  }
}
</style>
